home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / BBS-Archive / Comm / AmiTCP30b2.lha / src / netlib / herror.c < prev    next >
C/C++ Source or Header  |  1994-04-02  |  2KB  |  69 lines

  1. RCS_ID_C = "$Id: herror.c,v 3.2 1994/02/26 17:57:21 jraja Exp $";
  2. /*
  3.  * herror.c -- print host error message
  4.  *
  5.  * Author: jraja <Jarno.Rajahalme@hut.fi>
  6.  *
  7.  * Copyright © 1994 AmiTCP/IP Group, <AmiTCP-Group@hut.fi>
  8.  *                  Helsinki University of Technology, Finland.
  9.  *
  10.  * Created      : Wed Feb 16 09:38:17 1994 jraja
  11.  * Last modified: Sun Feb 27 03:45:29 1994 ppessi
  12.  *
  13.  */
  14.  
  15. /****** net.lib/herror *******************************************************
  16.  
  17.     NAME
  18.         herror - print name resolver error message to stderr.
  19.  
  20.     SYNOPSIS
  21.         #include <stdio.h>
  22.  
  23.         herror(banner)
  24.         void herror(const char *)
  25.  
  26.     FUNCTION
  27.         The herror() function finds the error message corresponding to the
  28.         current value of host error using the SocketBaseTags() and writes
  29.         it, followed by a newline, to the stderr. If the argument string
  30.         is non-NULL it is used as a prefix to the message string and
  31.         separated from it by a colon and space (`: '). If the argument is
  32.         NULL only the error message string is printed.
  33.  
  34.     NOTES
  35.         The herror() function requires the stdio functions to be linked.
  36.  
  37.     SEE ALSO
  38.         <netinclude:netdb.h>, SocketBaseTagList(), perror()
  39.  
  40. ******************************************************************************
  41. */
  42.  
  43. #include <stdio.h>
  44. #include <string.h>
  45. #include <bsdsocket.h>
  46. #include <amitcp/socketbasetags.h>
  47.  
  48. void 
  49. herror(const char *banner)
  50. {
  51.   const char *err;
  52.  
  53.   /*
  54.    * First fetch the h_errno value to (ULONG)err, and then convert it to 
  55.    * error string pointer.
  56.    */
  57.   SocketBaseTags(SBTM_GETREF(SBTC_HERRNO), &err,
  58.          SBTM_GETREF(SBTC_HERRNOSTRPTR), &err,
  59.          TAG_END);
  60.  
  61.   if (banner != NULL) {
  62.     fputs(banner, stderr);
  63.     fputs(": ", stderr);
  64.   }
  65.   fputs(err, stderr);
  66.   fputc('\n', stderr);
  67.   fflush(stderr);
  68. }
  69.